package com.letoken.platform.repo.app.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.letoken.platform.repo.app.po.RedEnvelopeConfig;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.math.BigDecimal;
import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author 作者
 * @since 2023-01-10
 */
public interface RedEnvelopeConfigMapper extends BaseMapper<RedEnvelopeConfig> {

    @Select("select maximum_times_per_day maximumTimesPerDay,maximum_daily_amount maximumDailyAmount from red_envelope_config where type = #{type}")
    RedEnvelopeConfig selectByType(@Param("type") Integer type);

    @Select("select type,maximum_times_per_day maximumTimesPerDay,maximum_daily_amount maximumDailyAmount from red_envelope_config")
    List<RedEnvelopeConfig> list();

    @Update("update red_envelope_config set maximum_times_per_day = #{maximumTimesPerDay}, maximum_daily_amount = #{maximumDailyAmount} where type = #{type} ")
    int updateByType(@Param("type") Integer type, @Param("maximumTimesPerDay") BigDecimal maximumTimesPerDay, @Param("maximumDailyAmount") BigDecimal maximumDailyAmount);

}
